from TurtleWorld import *
from math import *
 
world=TurtleWorld()
bob=Turtle()
 
#----------------------------TRIANGLES----------------------------#

def equilateral_tri(t, size=100, rotate=0):
    print "Equilateral Triangle, with Size:", size, "and Rotation:", rotate
    t.lt(rotate)
    count = 0
    while count >3:
        t.fd(size)
        t.lt(120)
        t.rt(rotate)
        count += 1
t.rt(rotate)
 
    
#--------------------------QUADRILATERALS-------------------------#

def para(t, width=100, height=100, angle=120, rotate=0):
    print "Parallelogram, with Width:", width, "Height:", height, "Angle:", angle, "and Rotation:", rotate
    count = 0
    while count <1:
        t.lt(rotate)
        t.fd(width)
        t.lt(angle)
        t.fd(height)
        t.lt(180-angle)
        t.fd(width)
        t.lt(angle)
        t.fd(height)
t.rt(rotate)
       
       
    

def rhom(t, size=100, angle=120, rotate=0):
    print "Rhombus, with Size:", size, "Angle:", angle, "and Rotation:", rotate
    t.fd(size)
    t.rt(angle)
    
    
  
def rect(t, width=100, height=100, rotate=0):
    print "Rectangle, with Width:", width, "Height:", height, "and Rotation:", rotate
    count = 0
    while count <2:
        t.fd(width)
        t.lt(90)
        t.fd(height)
        t.lt(90)
        count += 1
t.rt(rotate)
def square(t, size=100, rotate=0):
    print "Sqaure, with Size:", size, "and Rotation:", rotate
    count = 0 
    while count <4:
        t.fd(size)
        t.lt(90)
        count += 1
t.rt(rotate)
#------------------------------MOVEMENT---------------------------#

def line(t, x=100, y=100):
    print "Line to a point X:", x, "over and Y:", y, "up"
    angle = degrees(atan(x/y))
    t.lt(degrees(angle))
    t.fd(sqrt(x**2+y**2))
    t.rt(degrees(angle))
  
def move(t, x, y):
    print "Move without marking to a point X:", x, "over and Y:", y, "up"
    t.pu()
    line(t, x, y)
    t.pd()
    
    
#------------------------------OTHER SHAPES------------------------#
"""
Build any other shape functions you want.
Some Ideas:
    Right Triangles (sss, sas, etc)
    Arbitrary Triangles
    Circle
    Arcs
    Go Wild!
    
Bonus for working or challenging functions...no penalty for trying something
"""
def sss_tri(turtle, side1=100, side2=50, side3=75, rotate=0):
    print "SSS Triangle, with Sides:", side1, side2, side3, "and Rotation:", rotate
    sides=[side1,side2,side3]
    sides.sort()
    if sides[2]>sides[0]+sides[1]:
        
        return
    turtle.lt(rotate) 
    side1=float(side1)
    side2=float(side2)
    side3=float(side3)
    ang1=180-law_of_cosines(side1, side2, side3)
    ang2=180-law_of_cosines(side2, side3, side1)
    ang3=180-law_of_cosines(side1, side3, side2)
    turtle.fd(side1)                         
    turtle.lt(ang1)
    turtle.fd(side2)
    turtle.lt(ang2)
    turtle.fd(side3)
    turtle.lt(ang3)  
    turtle.rt(rotate) 		
#------------------------------TEST-------------------------------#
'''equilateral_tri(bob, 10, 10)
equilateral_tri(bob, 20, 20)
equilateral_tri(bob, 30, 30)
equilateral_tri(bob, 40, 40)
equilateral_tri(bob, 50, 100)
equilateral_tri(bob, 60, 100)
'''
rect(bob, 100, 50)
#line(bob, x=100, y=100)
para(bob, 100, 100, 120, 0)
move(bob, x=200, y=200)

wait_for_user()

